package com.yunhe.utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

public class JdbcUtils {
    static  DataSource dataSource;
    static {

        try {
            Properties ppt = new Properties();
            InputStream ras = JdbcUtils.class.getClassLoader().getResourceAsStream("durid.properties");
            ppt.load(ras);
            dataSource = DruidDataSourceFactory.createDataSource(ppt);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
  public  static DataSource getDataSource(){
        return dataSource;
  }
  public static Connection getConneCtion(){
      try {
          return  dataSource.getConnection();
      } catch (SQLException throwables) {
          throwables.printStackTrace();
      }
         return null;
  }
}
